<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>最佳合伙人</title>
<meta name="viewport" content="width=100%, initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/lib/weix/style/weui.min.css">
<link rel="stylesheet" href="/css/fonts.css">
<link rel="stylesheet" href="/css/comm.css">
<link rel="stylesheet" href="/css/list_rew.css">
<link rel="stylesheet" href="/css/index.css">
<style>
.qx_itme{ display:none;}
</style>
</head>

<body>
<div class="user_box">
	<div class="user_info">
    	<div class="name"><span id="J_name">---</span><span class="dj" id="J_role_name">---</span></div>
        <div class="ids"><span class="tb"><i class="icon-partner"></i></span>合伙人ID：<span id="J_code">---</span></div>
    </div>
    <div class="user_pic"><a href="/userPage/user_detail/${uid}?myself=0" id="J_avatar"></a></div>
</div>

<!--管理中心-->
<div id="J_guanl_box" class="qx_itme">
    <div class="weui-cells__title bg th-xx_top">管理中心</div>
    <div class="ind_grids th-xx_bot">
        <a class="ind_grid qx_itme J_qx_10004" href="/customerPage/customerList">
            <p class="tb"><i class="icon-file"></i></p>
            <p class="wz">报备</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10006" href="/orderPage/order_list?topen=3">
            <p class="tb"><i class="icon-money"></i></p>
            <p class="wz">开单</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10001" href="/userPage/group_user/2">
            <p class="tb" style="font-size:32px;"><i class="icon-staff"></i></p>
            <p class="wz">员工</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10008" href="/userPage/group_user/3">
            <p class="tb" style="font-size:26px;"><i class="icon-partner"></i></p>
            <p class="wz">合伙人</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10002" href="javascript:;">
            <p class="tb"><i class="icon-user"></i></p>
            <p class="wz">客户</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10007" href="javascript:;">
            <p class="tb"><i class="icon-task"></i></p>
            <p class="wz">任务</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10005" href="/productPage/productList">
            <p class="tb"><i class="icon-integral"></i></p>
            <p class="wz">积分</p>
        </a>
        <a class="ind_grid qx_itme J_qx_10003" href="/configPage/config">
            <p class="tb"><i class="icon-operation"></i></p>
            <p class="wz">设置</p>
        </a>
    </div>
</div>

<div class="weui-form-preview jif_box">
    <div class="weui-form-preview__bd jif_hd">
        <div class="jif_zc">
            <div class="mc">积分余额</div>
            <div class="szd num J_look_num on"><span class="s_1" id="J_balance">0</span><span class="s_2">****</span></div>
        </div>
        <div class="jif_yc">
            <div class="mc">累计积分</div>
            <div class="sz num J_look_num on"><span class="s_1" id="J_points">0</span><span class="s_2">****</span></div>
        </div>
        <a href="javascript:;" class="jif_look J_look on" id="J_points_show"><i class="icon-eye_close ico_1"></i><i class="icon-eye_open ico_2"></i></a>
    </div>
    <div class="weui-form-preview__ft">
        <a class="weui-form-preview__btn weui-form-preview__btn_default" href="/pointsPage/pointsList">明细</a>
        <a class="weui-form-preview__btn weui-form-preview__btn_default" href="javascript:;">兑换</a>
    </div>
</div>

<!--操作-->
<div class="weui-cells">
    <a class="weui-cell weui-cell_access qx_itme J_qx_10010" href="/customerPage/addCustomer">
        <div class="weui-cell__hd tb" style="background:#ff6e6e"><i class="icon-file"></i></div>
        <div class="weui-cell__bd">
            <p>客户报备</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access qx_itme J_qx_10011" href="/orderPage/create_order">
        <div class="weui-cell__hd tb" style="background:#fda906"><i class="icon-money"></i></div>
        <div class="weui-cell__bd">
            <p>优惠开单</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
    <a class="weui-cell weui-cell_access qx_itme J_qx_10009" href="/userPage/adduser?topen=3">
        <div class="weui-cell__hd tb" style="background:#f52e00"><i class="icon-partner"></i></div>
        <div class="weui-cell__bd">
            <p>添加合伙人</p>
        </div>
        <div class="weui-cell__ft"></div>
    </a>
</div>

<!--报备记录-->
<div class="qx_itme J_qx_10010">
    <div class="weui-cells__title bg th-xx_top">最新报备<a class="more" href="/customerPage/customerList">全部</a></div>
    <div class="weui-cells lib" id="J_baoList">
        <div class="weui-loadmore weui-loadmore_line">
            <span class="weui-loadmore__tips">暂无数据</span>
        </div>  
    </div>
</div>

<!--开单记录-->
<div class="qx_itme J_qx_10011">
    <div class="weui-cells__title bg th-xx_top">最新开单<a class="more" href="/orderPage/order_list?topen=1">全部</a></div>
    <div class="weui-cells lib" id="J_orderList">
        <div class="weui-loadmore weui-loadmore_line">
            <span class="weui-loadmore__tips">暂无数据</span>
        </div> 
    </div>
</div>

<!--最新成交-->
<div class="qx_itme J_qx_10010">
    <div class="weui-cells__title bg th-xx_top">最新成交<a class="more" href="/orderPage/order_list?topen=2">全部</a></div>
    <div class="weui-cells lib" id="J_chengjList">
        <div class="weui-loadmore weui-loadmore_line">
            <span class="weui-loadmore__tips">暂无数据</span>
        </div> 
    </div>
</div>

<!--新增合伙人-->
<div class="qx_itme J_qx_10009">
    <div class="weui-cells__title bg th-xx_top">新增合伙人<a class="more" href="/userPage/parner_list">全部</a></div>
    <div class="weui-cells lib" id="J_hehList">
        <div class="weui-loadmore weui-loadmore_line">
            <span class="weui-loadmore__tips">暂无数据</span>
        </div> 
    </div>
</div>

<!--最新任务-->
<div class="qx_itme J_qx_10012">
	<div class="weui-cells__title bg">最新任务<a class="more" href="javascript:;">全部</a></div>
    <div class="renw-boxs">
        <div class="renw-box">
            <div class="renw-box__zc"><p class="tian">13</p><p class="yue">11月</p></div>
            <div class="renw-box__yc">
                <a class="renw-box__tits" href="javascript:;">
                    <div class="renw-box__pic"><img src="/images/pic_160.png" /></div>
                    <div class="renw-box__name"><span class="lx">促销</span>五一店家大放价！东鹏长沙旗舰店5周年优惠就这一次!</div>
                    <div class="renw-box__jt"></div>
                </a>
                <div class="renw-box__info">
                    <p>时限：2018.11.12 — 2018.11.15</p>
                    <p>规则：1、认真阅读此条任务并转发获得阅读量；2、一个微信号只计一个阅读量；3、店员之间转发不计阅读量。</p>
                </div>
                <div class="renw-box__jf">
                    <p class="des">已获得<span class="ys">15</span>积分</p>
                    <p class="jia">3积分/阅读</p>
                </div>
            </div>
        </div>
        
    </div>
</div>


<!--<div class="weui-loadmore">
    <i class="weui-loading"></i>
    <span class="weui-loadmore__tips">正在加载</span>
</div>-->

<script src="/js/zepto.min.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="/js/comm.js"></script>
<script type="text/javascript">
//个人信息
function getUserDetail(){
	var id = "${uid}";
	var data = {id:id};
	var url = "/user/user_info";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var datas = res.data;
				$('#J_name').html(datas.name);
				$('#J_code').html(datas.code);
				$('#J_phone').html(datas.phone);
				$('#J_avatar').append("<img src='"+datas.avatar+"'>");
				$('#J_role_name').html(datas.roleName);
				$('#J_balance').html(datas.balance);
				$('#J_points').html(datas.points);
				$('#J_points_show').attr('data-num',datas.point_show)
				//--------------
				//初始化积分显示
				if(datas.point_show == 0){
					$('.J_look').removeClass('on')
					$('.J_look_num').removeClass('on')
				}else{
					$('.J_look').addClass('on')
					$('.J_look_num').addClass('on')
				}
				//--------------
				//初始化是否有管理中心栏目
				if(datas.pid != 3){		//2员工  3合伙人
					$('#J_guanl_box').show()
				}else{
					$('#J_guanl_box').hide()
				}
			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){

		},
		complete: function(){
		}
	});
}
//---------------------------
//权限
function quanx_csh(){
	var uid = "${uid}";
	var data = {uid:uid};
	var url = "/permission/mypermission";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var datas = res.data;
				
				for (var i = 0;i<datas.length;i++){
					var code_data = datas[i].code
					console.log(code_data)
					
					//code 10001员工管理 10002客户管理	10003设置管理 10004报备管理 10005积分管理 10006开单管理 10007任务管理 10008合伙人管理 10009添加合伙人  10010客户报备 10011优惠开单 10012做任务
					$('.J_qx_'+code_data+'').removeClass('qx_itme')

				}
				
			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){

		},
		complete: function(){
		}
	});
}

//---------------------------
//积分显示隐藏
function jig_ope(num){
	var uid= "${uid}";
	var data = {uid:uid,show:num};
	var url = "/user/point_show";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				return true
			}else{
				return false
			}
		},
		error: function(){

		},
		complete: function(){
		}
	});
}
//---------------------------
//报备
function baobeiList(page){
	var uid = "${uid}";
	var data = {page:1,rows:2,uid:uid,isall:0};
	var url = "/customer/customer_list";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var list = res.data.list;
				
				if(list.length > 0){
					$('#J_baoList').html('')
				}else{
					return false
				}
				
				for (var i = 0;i<list.length;i++){
					var shtml = '<a class="weui-cell weui-cell_access" href="/customerPage/customerDetail/'+list[i]['id']+'">'+
									'<div class="weui-cell__hd tb" style="color:#f52e00"><i class="icon-user"></i></div>'+
									'<div class="weui-cell__bd">'+
										'<p>'+list[i]['name']+' - '+list[i]['address']+'</p>'+
									'</div>'+
									'<div class="weui-cell__ft">'+list[i]['arrive']+'</div>'+
								'</a>'
					
					
					$('#J_baoList').append(shtml);
				}

			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){

		},
		complete: function(){
		}
	});
}
//---------------------------
//开单
function getOrderCordList(page){
	var uid = "${uid}";
	var data = {page:1,rows:2,uid:uid};
	var url = "/order/getDealOrder";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var list = res.data.list;
				
				if(list.length > 0){
					$('#J_orderList').html('')
				}else{
					return false
				}
				
				for (var i = 0;i<list.length;i++){
					var shtml = '<a class="weui-cell weui-cell_access" href="/orderPage/order/'+list[i]['id']+'">'+
									'<div class="weui-cell__hd tb" style="color:#f52e00"><i class="icon-money"></i></div>'+
									'<div class="weui-cell__bd">'+
										'<p>'+list[i]['name']+' - '+list[i]['address']+'</p>'+
									'</div>'+
									'<div class="weui-cell__ft">￥'+list[i]['total_money']+'</div>'+
								'</a>'
					
					
					$('#J_orderList').append(shtml);
				}

			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){

		},
		complete: function(){
		}
	});
}
//---------------------------
//成交
function chengj_List(page){
	var uid = "${uid}";
	var data = {page:1,rows:2,uid:uid};
	var url = "/order/order_list";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var list = res.data.list;
				
				if(list.length > 0){
					$('#J_chengjList').html('')
				}else{
					return false
				}
				
				for (var i = 0;i<list.length;i++){
					var shtml = '<a class="weui-cell weui-cell_access" href="/orderPage/order/'+list[i]['id']+'">'+
									'<div class="weui-cell__hd tb" style="color:#f52e00"><i class="icon-tick"></i></div>'+
									'<div class="weui-cell__bd">'+
										'<p>'+list[i]['name']+' - '+list[i]['address']+'</p>'+
									'</div>'+
									'<div class="weui-cell__ft">+'+list[i]['points']+'</div>'+
								'</a>'

					$('#J_chengjList').append(shtml);
				}

			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){
		},
		complete: function(){
		}
	});
}
//---------------------------
//合伙人
function hehList(page){
	var uid = "${uid}";
	var data = {page:1,rows:2,uid:uid};
	var url = "/user/getUserListByUid";
	$.ajax({
		type: "POST",
		async: false,
		dataType: 'json',
		contentType: "application/json; charset=utf-8",
		data: JSON.stringify(data),
		url: url,
		success: function(res){
			if(res.code == 200){
				var list = res.data.list;
				
				if(list.length > 0){
					$('#J_hehList').html('')
				}else{
					return false
				}
				
				for (var i = 0;i<list.length;i++){
					var shtml = '<a class="weui-cell weui-cell_access" href="/userPage/getParter/'+list[i]['id']+'">'+
									'<div class="weui-cell__hd tb" style="color:#f52e00"><i class="icon-partner"></i></div>'+
									'<div class="weui-cell__bd">'+
										'<p>'+list[i]['name']+' - '+list[i]['role_name']+'</p>'+
									'</div>'+
									'<div class="weui-cell__ft">+'+list[i]['point']+'</div>'+
								'</a>'

					$('#J_hehList').append(shtml)
				}

			}else{
				weui.topTips(res.msg);
			}
		},
		error: function(){
		},
		complete: function(){
		}
	});
}	

$(function(){	
	tits() //标题
	//返回本页刷新
	window.addEventListener("pageshow", function(){
		if(sessionStorage.getItem("need-refresh")){
			location.reload();
			sessionStorage.removeItem("need-refresh");
		}
	});	
	//-----------------------------------------------------------
	//初始化
	getUserDetail()			//个人信息
    quanx_csh()				//权限
	baobeiList()			//报备
	getOrderCordList()		//开单
	chengj_List()			//成交
	hehList()				//合伙人
	//-----------------------------------------------------------
	//积分关闭打开显示
	$(document).on('click','.J_look',function(){
		var $this_t = $(this)
		var num = $this_t.attr('data-num')
		
		var loading = weui.loading('加载中');
		
		if(num == 0){
			jig_ope(1)
			loading.hide();
			$this_t.attr('data-num',1).addClass('on')
			$('.J_look_num').addClass('on')
		}else if(num == 1){
			jig_ope(0)
			loading.hide();
			$this_t.attr('data-num',0).removeClass('on')
			$('.J_look_num').removeClass('on')
		}
	})
	//-----------------------------------------------------------
});
</script>
</body>
</html>